/**
  ******************************************************************************
  * File Name          : spiflash.h
  * Description        : This file contains all the functions prototypes for 
  *                      the spiflash  
  ******************************************************************************
  * @attention
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __SPIFLASH_H
#define __SPIFLASH_H

#include <stdint.h>
#include "fmc_operation.h"

/* spiflash 相关地址定义 */
#define SFLASH_IDPARA_ADDR          0x00000000u
#define SFLASH_SYSCFG_ADDR          0x00001000u
#define SFLASH_SYSRIL_ADDR          0x00002000u
#define SFLASH_CTRMD_ADDR           0x00003000u
#define SFLASH_CTRJT_ADDR           0x00004000u
#define SFLASH_CTRDL1_ADDR          0x00005000u
#define SFLASH_CTRDL2_ADDR          0x00006000u
#define SFLASH_CTRSK_ADDR           0x00007000u
#define SFLASH_CTRTD_ADDR           0x00008000u
#define SFLASH_CTRDK_ADDR           0x00009000u

#define CFLASH_DEVLIST_ADDR         0x08060000u

extern void sFlash_Init(void);
extern void spitest(void);
extern void sFlash_ReadChipID(uint8_t *rbuf);
extern void sFlash_AnywhereRead(uint32_t addr, uint8_t *rbuf, uint32_t length);
extern void sFlash_SectorErase(uint32_t addr);
extern void sFlash_Block32Erase(uint32_t addr);
extern void sFlash_Block64Erase(uint32_t addr);
extern void sFlash_ChipErase(void);
extern void sFlash_PageAlignedProgram(uint32_t addr, uint8_t *wbuf, uint32_t length);
extern void sFlash_SectorAlignedProgram(uint32_t addr, uint8_t *wbuf, uint32_t length);
extern void sFlash_AnywhereProgram(uint32_t addr, uint8_t *wbuf, uint32_t length);

#endif /* __SPIFLASH_H */
